const http = require('http')

const server = http.createServer()

server.on('request', (req, res) => {
  // req.url 获取请求的 url
  // req.method 获取请求的 method
  // req.headers 获取请求的 headers
  const url = req.url
  const method = req.method
  const str = `Your request url is ${url}, and request method is ${method}`
  console.log(str)
  // 设置响应头  设置响应体
  res.end(str)
})

server.listen(80, () => {
  console.log('http server running at http://127.0.0.1')
})